<template>
  <!-- 购物车列表 -->
  <div class="cart">
    <div class="shopcar">
      <div class="shopcar-headerleft">
        <i class="el-icon-picture-outline"></i>
        <span>购物车可领优惠券</span>
      </div>
      <div class="shopcar-headerright">
        <el-button type="danger"
          >领券<i class="el-icon-arrow-down"></i
        ></el-button>

        <i></i>
      </div>
    </div>

    <div class="cart-main">
      <div class="cart-th">
        <div class="cart-th1">全选</div>
        <div class="cart-th2">商品</div>
        <div class="cart-th4">单价</div>
        <div class="cart-th4">数量</div>
        <div class="cart-th5">小计（元）</div>
        <div class="cart-th6">操作</div>
      </div>
      <div class="main-body">
        <div>
          <div class="redemption">
            <span>全场换购</span><span>已满足1件享低至2.5折超值换购</span
            ><a>去换购</a><a>继续凑单&gt;&gt;</a>
          </div>
        </div>
      </div>
      <div class="cart-body">
        <ul class="cart-list">
          <li class="cart-list-con1">
            <input type="checkbox" name="chk_list" class="check" />
          </li>
          <li class="cart-list-con2">
            <img :src="smallImage[0]?.img" />
            <div class="item-msg">
              {{ shopcarList.title }}
            </div>
          </li>

          <li class="cart-list-con4">
            <span class="price">{{ shopcarList.price }}</span>
          </li>
          <li class="cart-list-con5">
            <a
              href="javascript:void(0)"
              class="mins"
              @click="
                shopcarList.number <= 1
                  ? (shopcarList.number = 1)
                  : shopcarList.number--
              "
              >-</a
            >
            <input
              autocomplete="off"
              type="text"
              v-model="shopcarList.number"
              minnum="1"
              class="itxt"
            />
            <a
              href="javascript:void(0)"
              class="plus"
              @click="shopcarList.number++"
              >+</a
            >
          </li>
          <li class="cart-list-con6">
            <span class="sum">{{ totalNum }}</span>
          </li>
          <li class="cart-list-con7">
            <a href="#none" class="sindelet">移入收藏夹</a>
            <a href="#none" class="sindelet">删除</a>
            <br />
          </li>
        </ul>
      </div>
    </div>
    <div class="cart-tool">
      <div class="select-all">
        <input class="chooseAll check" type="checkbox" />
        <span>已选(1)</span>
      </div>
      <div class="option">
        <a href="#none">批量删除</a>
      </div>
      <div class="option">
        <a href="#none">清空失效产品</a>
      </div>

      <div class="money-box">
        <div class="chosed">
          商品合计:<span>￥{{ totalNum }}元</span>

          <span>已优惠0元</span>
        </div>
        <div class="sumprice">
          <em>总价（不含运费） ：</em>

          <i class="summoney">{{ totalNum }}</i>
        </div>

        <div class="sumbtn">
          <router-link :to="{ path: '/confirmAddress' }">下单</router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { reqDetailData } from "@/api/index";

export default {
  name: "ShopCar",
  data() {
    return {
      goodsNumId: this.$route.params.id,
      shopcarList: {},
    };
  },
  async mounted() {
    this.shopcarList = await reqDetailData(this.goodsNumId);
  },

  computed: {
    smallImage() {
      return this.shopcarList.smallImage || [];
    },
    totalNum() {
      return this.shopcarList.price * this.shopcarList.number;
    },
  },
};
</script>

<style scoped lang="less">
.shopcar {
  width: 1090px;
  margin-bottom: 12px;
}
.shopcar-headerleft {
  text-align: left;
  width: 990px;
  height: 40px;
  margin-top: 10px;
  border: 1px solid #eaeaea;
  line-height: 38px;
  display: inline-block;
}
.shopcar-headerright {
  text-align: left;
  width: 80px;
  height: 40px;
  margin-top: 10px;
  border: 1px solid #eaeaea;
  line-height: 38px;
  display: inline-block;
  background-color: #e36844;
}

.cart {
  width: 1090px;
  margin: 0 auto;
}
.cart h4 {
  margin: 9px 0;
  font-size: 14px;
  line-height: 21px;
}
.cart .cart-main .cart-th {
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 10px;
  overflow: hidden;
}
.cart .cart-main .cart-th > div {
  float: left;
}
.cart .cart-main .cart-th .cart-th1 {
  width: 15%;
}
.cart .cart-main .cart-th .cart-th1 input {
  vertical-align: middle;
}
.cart .cart-main .cart-th .cart-th1 span {
  vertical-align: middle;
}
.cart .cart-main .cart-th .cart-th2 {
  width: 26%;
}
.cart .cart-main .cart-th .cart-th3,
.cart .cart-main .cart-th .cart-th4,
.cart .cart-main .cart-th .cart-th5,
.cart .cart-main .cart-th .cart-th6 {
  width: 13.5%;
}
.cart .cart-main .cart-body {
  margin: 15px 0;
  border: 1px solid #ddd;
}
.cart .cart-main .cart-body .cart-list {
  padding: 15px;
  border-bottom: 1px solid #ddd;
  overflow: hidden;
  background-color: #fffbf0;
}
.cart .cart-main .cart-body .cart-list > li {
  float: left;
}
.cart .cart-main .cart-body .cart-list .cart-list-con1 {
  width: 5%;
  margin-top: 25px;
}
.cart .cart-main .cart-body .cart-list .cart-list-con2 {
  width: 35%;
}
.cart .cart-main .cart-body .cart-list .cart-list-con2 img {
  width: 82px;
  height: 82px;
  float: left;
}
.cart .cart-main .cart-body .cart-list .cart-list-con2 .item-msg {
  float: left;
  width: 150px;
  margin: 0 10px;
  line-height: 18px;
}
.cart .cart-main .cart-body .cart-list .cart-list-con4 {
  width: 12%;
}
.cart .cart-main .cart-body .cart-list .cart-list-con5 {
  width: 17%;
}
.cart .cart-main .cart-body .cart-list .cart-list-con5 .mins {
  border: 1px solid #ddd;
  border-right: 0;
  float: left;
  color: #666;
  width: 6px;
  text-align: center;
  padding: 8px;
}
.cart .cart-main .cart-body .cart-list .cart-list-con5 input {
  border: 1px solid #ddd;
  width: 40px;
  height: 33px;
  float: left;
  text-align: center;
  font-size: 14px;
}
.cart .cart-main .cart-body .cart-list .cart-list-con5 .plus {
  border: 1px solid #ddd;
  border-left: 0;
  float: left;
  color: #666;
  width: 6px;
  text-align: center;
  padding: 8px;
}
.cart .cart-main .cart-body .cart-list .cart-list-con6 {
  width: 12%;
}
.cart .cart-main .cart-body .cart-list .cart-list-con6 .sum {
  font-size: 16px;
}
.cart .cart-main .cart-body .cart-list .cart-list-con7 {
  width: 13%;
}
.cart .cart-main .cart-body .cart-list .cart-list-con7 a {
  color: #666;
}
.cart .cart-tool {
  overflow: hidden;
  border: 1px solid #ddd;
}
.cart .cart-tool .select-all {
  padding: 10px;
  overflow: hidden;
  float: left;
}
.cart .cart-tool .select-all span {
  vertical-align: middle;
}
.cart .cart-tool .select-all input {
  vertical-align: middle;
}
.cart .cart-tool .option {
  padding: 10px;
  overflow: hidden;
  float: left;
}
.cart .cart-tool .option a {
  float: left;
  padding: 0 10px;
  color: #666;
}
.cart .cart-tool .money-box {
  float: right;
}
.cart .cart-tool .money-box .chosed {
  line-height: 26px;
  float: left;
  padding: 0 10px;
}
.cart .cart-tool .money-box .sumprice {
  width: 200px;
  line-height: 22px;
  float: left;
  padding: 0 10px;
}
.cart .cart-tool .money-box .sumprice .summoney {
  color: #c81623;
  font-size: 16px;
}
.cart .cart-tool .money-box .sumbtn {
  float: right;
}
.cart .cart-tool .money-box .sumbtn a {
  display: block;
  position: relative;
  width: 96px;
  height: 52px;
  line-height: 52px;
  color: #fff;
  text-align: center;
  font-size: 18px;
  font-family: "Microsoft YaHei";
  background: #b4a078;
  overflow: hidden;
}
.check {
  width: 18px;
  height: 18px;
}
.main-body {
  height: 45px;
  margin-top: 16px;
  line-height: 45px;
  background-color: #fffbf0;
  border: 1px solid #ddd;
}

.redemption {
  padding-left: 55px;
}
</style>
